package cate.game.pvp;


import java.util.function.Consumer;

public abstract class AbstractPvpSeasonPeriod<E> {
    private long startTime;

    private long endTime;

    private int period;

    private String nameDesc;

    public AbstractPvpSeasonPeriod(){

    }

    public AbstractPvpSeasonPeriod(long startTime, long endTime, int period, String nameDesc){
        this.startTime = startTime;
        this.endTime = endTime;
        this.period = period;
        this.nameDesc = nameDesc;
    }

    public long getStartTime() {
        return startTime;
    }

    public void setStartTime(long startTime) {
        this.startTime = startTime;
    }

    public long getEndTime() {
        return endTime;
    }

    public void setEndTime(long endTime) {
        this.endTime = endTime;
    }

    public void setPeriod(int period) {
        this.period = period;
    }

    public String getNameDesc() {
        return nameDesc;
    }

    public void setNameDesc(String nameDesc) {
        this.nameDesc = nameDesc;
    }

    public int getPeriod(){
        return this.period;
    }

    @Override
    public String toString(){
        return this.nameDesc;
    }

    protected abstract Consumer<E> getHandler();

    public void handle(E e){
        if(getHandler() != null){
            getHandler().accept(e);
        }
    }
}
